package com.learn.screw.generate;

import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * Screw配置
 */
@Data
@ConfigurationProperties(prefix = ScrewProperties.PREFIX)
public class ScrewProperties {

    public static final String PREFIX = "screw";

    /**
     * 生成文件路径
     */
    private String fileOutputDir;

    /**
     * 打开目录
     */
    private Boolean openOutputDir;

    /**
     * 文件类型
     */
    private EngineFileType fileType;

    /**
     * 生成模板实现
     */
    private EngineTemplateType produceType;

    /**
     * 自定义文件名称
     */
    private String fileName;

    /**
     * 忽略表
     */
    @Value("#{'${ignoreTableName:}'.empty ? null : '${ignoreTableName:}'.split(',')}")
    private List<String> ignoreTableName;

    /**
     * 忽略表前缀
     */
    @Value("#{'${ignorePrefix:}'.empty ? null : '${ignorePrefix:}'.split(',')}")
    private List<String> ignorePrefix;

    /**
     * 忽略表后缀
     */
    @Value("#{'${ignoreSuffix:}'.empty ? null : '${ignoreSuffix:}'.split(',')}")
    private List<String> ignoreSuffix;

    /**
     * 根据名称指定表生成
     */
    @Value("#{'${designatedTableName:}'.empty ? null : '${designatedTableName:}'.split(',')}")
    private List<String> designatedTableName;

    /**
     * 根据表前缀生成
     */
    @Value("#{'${designatedTablePrefix:}'.empty ? null : '${designatedTablePrefix:}'.split(',')}")
    private List<String> designatedTablePrefix;

    /**
     * 根据表后缀生成
     */
    @Value("#{'${designatedTableSuffix:}'.empty ? null : '${designatedTableSuffix:}'.split(',')}")
    private List<String> designatedTableSuffix;

    /**
     * 文档一般信息
     */
    private Common common = new Common();

    /**
     * static
     */
    @Data
    public static class Common {

        private String organization;

        private String organizationUrl;

        private String title;

        /**
         * 版本
         */
        private String version = "1.0.0";

        /**
         * 描述
         */
        private String description = "数据库设计文档生成";
    }
}
